﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ThemTinTuc : System.Web.UI.Page
{
    DataTable dt = new DataTable();
    KetNoi obj = new KetNoi();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Calendar1.SelectedDate = DateTime.Today;
           
        }
    }

    private void luuhinh(FileUpload a)// Luu Hinh
    {
        string strfilename;
        if (a.FileName != "")
        {
            strfilename = Server.MapPath("Upload\\" + a.FileName);
            a.PostedFile.SaveAs(strfilename);
        }
    }
    protected void XoaText()
    {

        txttieude.Text = "";
        txtnoidungtt.Text = "";
      
    }


    protected void btnLuu_Click1(object sender, EventArgs e)
    {
        
        luuhinh(FileUploadHinh);
        //luuhinh(FileUploaddetal);
        string tieude = txttieude.Text.ToString();
        string noidungtomtat = txtnoidungtt.Text.ToString();
        string noidung = TextBox1.Text.ToString();
        DateTime ngaydang = Calendar1.SelectedDate;
        string hinhanh = FileUploadHinh.FileName.ToString();
        obj.ThemTinTuc(tieude, noidungtomtat, noidung, ngaydang, hinhanh);
        string mess = "Bạn đã lưu thành công";
        string strBuilder = "<script language='javascript'>alert('" + mess + "')</script>";
        Response.Write(strBuilder);
        XoaText();
    }
    protected void btnlamlai_Click(object sender, EventArgs e)
    {
        XoaText();
    }
}
